package com.situ.mall.pattern.jdkobserver;

import java.util.Observable;
import java.util.Observer;

public class Reader implements Observer {
    private String name;

    public Reader(String name) {
        this.name = name;
    }

    @Override
    public void update(Observable o, Object arg) {
        //这是采用推的方式
        System.out.println(name + "收到报纸，本期内容： " + arg);
        //采用拉的方法
        NewsPaper newspaper = (NewsPaper) o;
        System.out.println(name + "收到报纸，本期内容： " + newspaper.getContent());
    }
}
